package cn.com.api.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Select;

import cn.com.api.entity.ApiU_discover_spec;
import cn.com.api.mapper.base.U_discover_specMapperBase;

//DAO
public interface ApiU_discover_specMapper extends U_discover_specMapperBase {

 	//新增对象后返回记录ID
    public int U_discover_specInsertion(ApiU_discover_spec u_discover_spec);
    
    @Select("select t.*, count(n.product_id)as spec_count from ( SELECT * FROM U_DISCOVER_SPEC  WHERE CONN_ID = #{discover_id})t left join " 
                                      +"(select * from t_order r left join t_order_detail d on r.ORDERNUM = d.did "
                                      +"where r.ORDERTYPE = '8' and d.target_id = #{discover_id}  )n  on  t.id = n.product_id "
                                      +"group by t.id, t.conn_id,t.price_name, t.price, t.limit, t.sort, t.type")
    public List<ApiU_discover_spec> getApiU_discover_specsBydiscover_Id(String discover_id);
    
    
    //删除
    @Delete("DELETE FROM U_DISCOVER_SPEC  WHERE CONN_ID = #{conn_id}")
    public int deleteU_discover_spec_byconnid(Integer id);

    
}


